<?php
if (isset($_POST['submit_second'])) {
	if (file_exists("../_libs/mysql.php")) {
		chmod("../_libs/mysql.php", 0777);
		$array = file("../_libs/mysql.php"); // Datei in ein Array einlesen
		// Zeile 5 wird geändert
		// (das Array fängt mit dem Zählen bei 0 an)
		array_splice($array, 11, 1, "define('DB_HOST', '" . $_POST['serverip'] . "');\n");
		array_splice($array, 12, 1, "define('DB_USER', '" . $_POST['sql_user'] . "');\n");
		array_splice($array, 13, 1, "define('DB_PASS', '" . $_POST['sql_pass'] . "');\n");

		// Array-Elemente zu einem String (Zeichenkette) verbinden
		$string = implode("", $array);
		// Text in Datei schreiben und speichern
		file_put_contents("../_libs/mysql.php", $string);
		echo '<meta http-equiv="refresh" content="0; URL=?i=step3">';
	} else {
		die('Some Problems with mysql.php');
	}
}
?>

<!-- #second_step -->
<div >
	<div class="form">
		<table cellpadding="2" cellspacing="1" class="table" style="width:95%;">
			<tr>
				<td colspan="2">Please add your Database Connection</td>
			</tr>
			<tr>
				<td class="td_title">Your ServerIP</td>
				<td class="td_content"><input type="text" name="serverip" id="serverip" value="localhost" /></td>
			</tr>
			<tr>
				<td class="td_title">Your SQL User</td>
				<td class="td_content"><input type="text" name="sql_user" id="sql_user" value="root" /></td>
			</tr>
			<tr>
				<td class="td_title">Your SQL Password</td>
				<td class="td_content"><input type="password" name="sql_pass" id="password" /></td>
			</tr>
		</table>
	</div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->
	<input class="submit" type="submit" name="submit_second" id="submit_second" value="" />
</div>      <!-- clearfix --><div class="clear"></div><!-- /clearfix -->